package frame.networks.viewers.viewer;

import model.components.links.link.Link;
import model.components.nodes.node.Node;

import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse;
import edu.uci.ics.jung.visualization.decorators.EdgeShape;
import edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position;
import frame.MopraFrame;

@SuppressWarnings("serial")
public class NetworkVisualizationViewer extends VisualizationViewer< Node, Link >
{
	private NetworkPopupGraphMousePlugin networkPopupGraphMousePlugin;
	public NetworkPopupGraphMousePlugin getNetworkPopupGraphMousePlugin(){ return networkPopupGraphMousePlugin; }
	public void setNetworkPopupGraphMousePlugin( NetworkPopupGraphMousePlugin networkPopupGraphMousePlugin ){ this.networkPopupGraphMousePlugin = networkPopupGraphMousePlugin; }
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public NetworkVisualizationViewer( Layout< Node, Link > layout, MopraFrame mopraFrame )
	{
		super( layout );
		
		this.setNetworkPopupGraphMousePlugin( new NetworkPopupGraphMousePlugin( mopraFrame ) );
			
		this.getRenderContext().setVertexIconTransformer( new NodeIconTransformer() );
		this.getRenderContext().setVertexLabelTransformer( new NodeLabelTransformer() );
		this.getRenderContext().setEdgeShapeTransformer( new EdgeShape.CubicCurve() );
		this.getRenderContext().setEdgeDrawPaintTransformer( new LinkColorTransformer() );
		this.getRenderer().getVertexLabelRenderer().setPosition( Position.AUTO );
			
		DefaultModalGraphMouse< Node, Link > defaultModalGraphMouse = new DefaultModalGraphMouse< Node, Link >();
		defaultModalGraphMouse.setMode( DefaultModalGraphMouse.Mode.TRANSFORMING );
		defaultModalGraphMouse.add( this.getNetworkPopupGraphMousePlugin() );
	        
		this.addKeyListener( defaultModalGraphMouse.getModeKeyListener() );
		this.setGraphMouse( defaultModalGraphMouse );
	}
	
}
